﻿using FluentData;
using SYS.Web.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SYS.Web.config
{
    public class SiteList
    {
        public List<Site> list = new List<Site>();
        public static int SiteI = 1;
        public SiteList() {
            list.Add(this.GetDefault("http://www.t0.com:7646/",1));
            list.Add(this.GetDefault("http://www.t1.com:7646/",2));
            list.Add(this.GetDefault("http://www.t2.com:7646/",3));
            list.Add(this.GetDefault("http://www.t3.com:7646/",4));
            list.Add(this.GetDefault("http://www.t4.com:7646/",5));
            list.Add(this.GetDefault("http://www.t5.com:7646/",6));
            list.Add(this.GetDefault("http://www.t6.com:7646/",7));
            list.Add(this.GetDefault("http://www.t7.com:7646/",8));
            list.Add(this.GetDefault("http://www.t8.com:7646/",9));
            list.Add(this.GetDefault("http://www.t9.com:7646/",10));
            list.Add(this.GetDefault("http://www.t10.com:7646/",11));
            list.Add(this.GetDefault("http://www.t11.com:7646/",12));
            list.Add(this.GetDefault("http://www.t12.com:7646/",13));
            list.Add(this.GetDefault("http://www.t13.com:7646/",14));
            list.Add(this.GetDefault("http://www.t14.com:7646/",15));
            list.Add(this.GetDefault("http://www.t15.com:7646/",16));
        }
        public Site GetSite(string url) {
            Site site= list.Where(s => s.SiteUrl.Contains(url)).SingleOrDefault();
            if (site==null)
            {
                throw new Exception(url);
            }
            return site;
        }

        public Site GetDefault(string url,int siteId) {
            Site site = new Site();
            site.SiteGroup = 0;
            site.SiteId = siteId;
            site.UrlPrefix = siteId.ToString();
            site.SiteUrl = url;
            site.SiteName = "test_"+url;
            site.SiteTitle = "{key},{key}排行榜,{key}_{key1},淘宝{key2},{key}怎么样";
            site.SiteSkin = "t2";
            site.SiteStaticFile = "/static/template2";
            site.tdj_pid = "mm_33315358_4074343_13252004";
            site._51_la_id = "15932201";
            site.CharArray = "jdhstiwycx";
            site.UrlExtension = "/";
            site.DBConString = "server=.;User ID=sa;Password=111111;database=test;Connection Reset=FALSE";
            site.DbProvider = new SqlServerProvider();
            return site;
        }
    }
}